package config

import "github.com/spf13/viper"

type ViperData struct {
	Mysql struct {
		Username string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Addr     string
		Password string
		DB       int
	}
}

type Nacos struct {
	NamespaceId string
	IpAddr      string
	Port        int
	DataId      string
	Group       string
}

var (
	Conf      ViperData
	NacosConf Nacos
)

func GetViperData() {
	viper.SetConfigFile("D:\\GOWORK\\zk3\\ctrip\\srv-server\\dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("配置文件读取失败")
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		panic("配置文件解析失败1")
	}
	err = viper.Unmarshal(&NacosConf)
	if err != nil {
		panic("配置文件解析失败2")
	}
}
